#pragma once

#include <iostream>
#include <string>
#include <vector>
#include <sstream>

const std::string sep = "\r\n";
const std::string LineSep=" ";
const std::string BlankLine = sep;

class HttpRequest
{
public:
    HttpRequest() {}
    ~HttpRequest() {}

    void Deserialize(std::string &request)
    {
        ParseOneLine(request, &_req_line, sep);
        //提取请求航中的详细字段
        ParseReqLine(_req_line,LineSep);
    }
private:
    // GET /favicon.ico HTTP/1.1  -> Get  /favicon.ico  HTTP/1.1
    void ParseReqLine(const std::string &req_line, const std::string sep)
    {
        std::stringstream ss(req_line);
        ss>>_method>>_uri>>_version;
    }
private:
    std::string _req_line;
    std::vector<std::string> _req_header;
    std::string _blank_line;
    std::string _body;

    //在反序列化的过程中，细化解析出来的字段
    std::string _method;
    std::string _uri;
    std::string _version;
};

class HttpResponse
{
private:
    std::string _resp_line;
    std::vector<std::string> _resp_header;
    std::string _blank_line;
};